package org.seeplnframework.skyeye.common.util;

import lombok.extern.slf4j.Slf4j;

import java.io.*;

/**
 * @author ly
 * @date 2023/1/3
 */
@Slf4j
public class K8sNameSpaceUtils {

    public static String getNameSpace() {
        try {
            InputStream inputStream = new FileInputStream("/var/run/secrets/kubernetes.io/serviceaccount/namespace");
            BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
            String namespace = reader.readLine();
            return namespace.trim();
        } catch (IOException e) {
            log.warn("sky eye read namespace fail.");
            return "unknown";
        }
    }
}
